#include<bits/stdc++.h>
using namespace std;

int a[100010];

int main()
{
	int n, m;
	cin>>n;
	for(int i = 1;i <= n;i++)
		cin>>a[i];
	cin>>m;
	while(m--)
	{
		int x;
		cin>>x;
		int index = lower_bound(a+1, a+n+1, x)-a;
		if(index > n)
			cout<<a[index-1]<<endl;
		else if(index == 1)
			cout<<a[index]<<endl;
		else if(x-a[index-1] <= a[index]-x)
			cout<<a[index-1]<<endl;
		else
			cout<<a[index]<<endl;
	}
	return 0;
}

